
<!DOCTYPE html>

<html>
  
<!-- Mirrored from docs.sympy.org/latest/modules/physics/quantum/hilbert.html by HTTrack Website Copier/3.x [XR&CO'2014], Sat, 15 Jan 2022 03:27:43 GMT -->
<!-- Added by HTTrack --><meta http-equiv="content-type" content="text/html;charset=utf-8" /><!-- /Added by HTTrack -->
<head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" /><meta name="generator" content="Docutils 0.17.1: http://docutils.sourceforge.net/" />

    <title>Hilbert Space &#8212; SymPy 1.9 documentation</title>
    <link rel="stylesheet" type="text/css" href="../../../_static/pygments.css" />
    <link rel="stylesheet" type="text/css" href="../../../_static/default.css" />
    <link rel="stylesheet" type="text/css" href="../../../_static/graphviz.css" />
    <link rel="stylesheet" type="text/css" href="../../../_static/plot_directive.css" />
    <link rel="stylesheet" type="text/css" href="../../../../../live.sympy.org/static/live-core.css" />
    <link rel="stylesheet" type="text/css" href="../../../../../live.sympy.org/static/live-autocomplete.css" />
    <link rel="stylesheet" type="text/css" href="../../../../../live.sympy.org/static/live-sphinx.css" />
    
    <script data-url_root="../../../" id="documentation_options" src="../../../_static/documentation_options.js"></script>
    <script src="../../../_static/jquery.js"></script>
    <script src="../../../_static/underscore.js"></script>
    <script src="../../../_static/doctools.js"></script>
    <script src="../../../../../live.sympy.org/static/utilities.js"></script>
    <script src="../../../../../live.sympy.org/static/external/classy.js"></script>
    <script src="../../../../../live.sympy.org/static/live-core.js"></script>
    <script src="../../../../../live.sympy.org/static/live-autocomplete.js"></script>
    <script src="../../../../../live.sympy.org/static/live-sphinx.js"></script>
    
    <link rel="shortcut icon" href="../../../_static/sympy-notailtext-favicon.ico"/>
    <link href="hilbert.html" rel="canonical" />
    
    <link rel="index" title="Index" href="../../../genindex.html" />
    <link rel="search" title="Search" href="../../../search.html" />
    <link rel="next" title="Operator" href="operator.html" />
    <link rel="prev" title="Cartesian Operators and States" href="cartesian.html" /> 
  </head><body>
    <div class="related" role="navigation" aria-label="related navigation">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="../../../genindex.html" title="General Index"
             accesskey="I">index</a></li>
        <li class="right" >
          <a href="../../../py-modindex.html" title="Python Module Index"
             >modules</a> |</li>
        <li class="right" >
          <a href="operator.html" title="Operator"
             accesskey="N">next</a> |</li>
        <li class="right" >
          <a href="cartesian.html" title="Cartesian Operators and States"
             accesskey="P">previous</a> |</li>
        <li class="nav-item nav-item-0"><a href="../../../index.html">SymPy 1.9 documentation</a> &#187;</li>
          <li class="nav-item nav-item-1"><a href="../../index.html" >SymPy Modules Reference</a> &#187;</li>
          <li class="nav-item nav-item-2"><a href="../index.html" >Physics</a> &#187;</li>
          <li class="nav-item nav-item-3"><a href="index.html" accesskey="U">Quantum Mechanics</a> &#187;</li>
        <li class="nav-item nav-item-this"><a href="#">Hilbert Space</a></li> 
      </ul>
    </div>  

    <div class="document">
      <div class="documentwrapper">
        <div class="bodywrapper">
          <div class="body" role="main">
            
  <section id="module-sympy.physics.quantum.hilbert">
<span id="hilbert-space"></span><h1>Hilbert Space<a class="headerlink" href="#module-sympy.physics.quantum.hilbert" title="Permalink to this headline">¶</a></h1>
<p>Hilbert spaces for quantum mechanics.</p>
<p>Authors:
* Brian Granger
* Matt Curry</p>
<dl class="py class">
<dt class="sig sig-object py" id="sympy.physics.quantum.hilbert.ComplexSpace">
<em class="property"><span class="pre">class</span> </em><span class="sig-prename descclassname"><span class="pre">sympy.physics.quantum.hilbert.</span></span><span class="sig-name descname"><span class="pre">ComplexSpace</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">dimension</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/physics/quantum/hilbert.py#L109-L182"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.physics.quantum.hilbert.ComplexSpace" title="Permalink to this definition">¶</a></dt>
<dd><p>Finite dimensional Hilbert space of complex vectors.</p>
<p>The elements of this Hilbert space are n-dimensional complex valued
vectors with the usual inner product that takes the complex conjugate
of the vector on the right.</p>
<p>A classic example of this type of Hilbert space is spin-1/2, which is
<code class="docutils literal notranslate"><span class="pre">ComplexSpace(2)</span></code>. Generalizing to spin-s, the space is
<code class="docutils literal notranslate"><span class="pre">ComplexSpace(2*s+1)</span></code>.  Quantum computing with N qubits is done with the
direct product space <code class="docutils literal notranslate"><span class="pre">ComplexSpace(2)**N</span></code>.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">symbols</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.physics.quantum.hilbert</span> <span class="kn">import</span> <span class="n">ComplexSpace</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">c1</span> <span class="o">=</span> <span class="n">ComplexSpace</span><span class="p">(</span><span class="mi">2</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">c1</span>
<span class="go">C(2)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">c1</span><span class="o">.</span><span class="n">dimension</span>
<span class="go">2</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">n</span> <span class="o">=</span> <span class="n">symbols</span><span class="p">(</span><span class="s1">&#39;n&#39;</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">c2</span> <span class="o">=</span> <span class="n">ComplexSpace</span><span class="p">(</span><span class="n">n</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">c2</span>
<span class="go">C(n)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">c2</span><span class="o">.</span><span class="n">dimension</span>
<span class="go">n</span>
</pre></div>
</div>
</dd></dl>

<dl class="py class">
<dt class="sig sig-object py" id="sympy.physics.quantum.hilbert.DirectSumHilbertSpace">
<em class="property"><span class="pre">class</span> </em><span class="sig-prename descclassname"><span class="pre">sympy.physics.quantum.hilbert.</span></span><span class="sig-name descname"><span class="pre">DirectSumHilbertSpace</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="o"><span class="pre">*</span></span><span class="n"><span class="pre">args</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/physics/quantum/hilbert.py#L439-L546"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.physics.quantum.hilbert.DirectSumHilbertSpace" title="Permalink to this definition">¶</a></dt>
<dd><p>A direct sum of Hilbert spaces <a class="reference internal" href="#r629" id="id1"><span>[R629]</span></a>.</p>
<p>This class uses the <code class="docutils literal notranslate"><span class="pre">+</span></code> operator to represent direct sums between
different Hilbert spaces.</p>
<p>A <code class="docutils literal notranslate"><span class="pre">DirectSumHilbertSpace</span></code> object takes in an arbitrary number of
<code class="docutils literal notranslate"><span class="pre">HilbertSpace</span></code> objects as its arguments. Also, addition of
<code class="docutils literal notranslate"><span class="pre">HilbertSpace</span></code> objects will automatically return a direct sum object.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.physics.quantum.hilbert</span> <span class="kn">import</span> <span class="n">ComplexSpace</span><span class="p">,</span> <span class="n">FockSpace</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">c</span> <span class="o">=</span> <span class="n">ComplexSpace</span><span class="p">(</span><span class="mi">2</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">f</span> <span class="o">=</span> <span class="n">FockSpace</span><span class="p">()</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">hs</span> <span class="o">=</span> <span class="n">c</span><span class="o">+</span><span class="n">f</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">hs</span>
<span class="go">C(2)+F</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">hs</span><span class="o">.</span><span class="n">dimension</span>
<span class="go">oo</span>
<span class="gp">&gt;&gt;&gt; </span><span class="nb">list</span><span class="p">(</span><span class="n">hs</span><span class="o">.</span><span class="n">spaces</span><span class="p">)</span>
<span class="go">[C(2), F]</span>
</pre></div>
</div>
<p class="rubric">References</p>
<dl class="citation">
<dt class="label" id="r629"><span class="brackets">R629</span><span class="fn-backref">(<a href="#id1">1</a>,<a href="#id2">2</a>)</span></dt>
<dd><p><a class="reference external" href="https://en.wikipedia.org/wiki/Hilbert_space#Direct_sums">https://en.wikipedia.org/wiki/Hilbert_space#Direct_sums</a></p>
</dd>
</dl>
<dl class="py method">
<dt class="sig sig-object py" id="sympy.physics.quantum.hilbert.DirectSumHilbertSpace.eval">
<em class="property"><span class="pre">classmethod</span> </em><span class="sig-name descname"><span class="pre">eval</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">args</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/physics/quantum/hilbert.py#L476-L494"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.physics.quantum.hilbert.DirectSumHilbertSpace.eval" title="Permalink to this definition">¶</a></dt>
<dd><p>Evaluates the direct product.</p>
</dd></dl>

<dl class="py property">
<dt class="sig sig-object py" id="sympy.physics.quantum.hilbert.DirectSumHilbertSpace.spaces">
<em class="property"><span class="pre">property</span> </em><span class="sig-name descname"><span class="pre">spaces</span></span><a class="headerlink" href="#sympy.physics.quantum.hilbert.DirectSumHilbertSpace.spaces" title="Permalink to this definition">¶</a></dt>
<dd><p>A tuple of the Hilbert spaces in this direct sum.</p>
</dd></dl>

</dd></dl>

<dl class="py class">
<dt class="sig sig-object py" id="sympy.physics.quantum.hilbert.FockSpace">
<em class="property"><span class="pre">class</span> </em><span class="sig-prename descclassname"><span class="pre">sympy.physics.quantum.hilbert.</span></span><span class="sig-name descname"><span class="pre">FockSpace</span></span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/physics/quantum/hilbert.py#L237-L279"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.physics.quantum.hilbert.FockSpace" title="Permalink to this definition">¶</a></dt>
<dd><p>The Hilbert space for second quantization.</p>
<p>Technically, this Hilbert space is a infinite direct sum of direct
products of single particle Hilbert spaces <a class="reference internal" href="#r630" id="id3"><span>[R630]</span></a>. This is a mess, so we have
a class to represent it directly.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.physics.quantum.hilbert</span> <span class="kn">import</span> <span class="n">FockSpace</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">hs</span> <span class="o">=</span> <span class="n">FockSpace</span><span class="p">()</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">hs</span>
<span class="go">F</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">hs</span><span class="o">.</span><span class="n">dimension</span>
<span class="go">oo</span>
</pre></div>
</div>
<p class="rubric">References</p>
<dl class="citation">
<dt class="label" id="r630"><span class="brackets">R630</span><span class="fn-backref">(<a href="#id3">1</a>,<a href="#id4">2</a>)</span></dt>
<dd><p><a class="reference external" href="https://en.wikipedia.org/wiki/Fock_space">https://en.wikipedia.org/wiki/Fock_space</a></p>
</dd>
</dl>
</dd></dl>

<dl class="py class">
<dt class="sig sig-object py" id="sympy.physics.quantum.hilbert.HilbertSpace">
<em class="property"><span class="pre">class</span> </em><span class="sig-prename descclassname"><span class="pre">sympy.physics.quantum.hilbert.</span></span><span class="sig-name descname"><span class="pre">HilbertSpace</span></span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/physics/quantum/hilbert.py#L39-L106"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.physics.quantum.hilbert.HilbertSpace" title="Permalink to this definition">¶</a></dt>
<dd><p>An abstract Hilbert space for quantum mechanics.</p>
<p>In short, a Hilbert space is an abstract vector space that is complete
with inner products defined <a class="reference internal" href="#r631" id="id5"><span>[R631]</span></a>.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.physics.quantum.hilbert</span> <span class="kn">import</span> <span class="n">HilbertSpace</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">hs</span> <span class="o">=</span> <span class="n">HilbertSpace</span><span class="p">()</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">hs</span>
<span class="go">H</span>
</pre></div>
</div>
<p class="rubric">References</p>
<dl class="citation">
<dt class="label" id="r631"><span class="brackets">R631</span><span class="fn-backref">(<a href="#id5">1</a>,<a href="#id6">2</a>)</span></dt>
<dd><p><a class="reference external" href="https://en.wikipedia.org/wiki/Hilbert_space">https://en.wikipedia.org/wiki/Hilbert_space</a></p>
</dd>
</dl>
<dl class="py property">
<dt class="sig sig-object py" id="sympy.physics.quantum.hilbert.HilbertSpace.dimension">
<em class="property"><span class="pre">property</span> </em><span class="sig-name descname"><span class="pre">dimension</span></span><a class="headerlink" href="#sympy.physics.quantum.hilbert.HilbertSpace.dimension" title="Permalink to this definition">¶</a></dt>
<dd><p>Return the Hilbert dimension of the space.</p>
</dd></dl>

</dd></dl>

<dl class="py class">
<dt class="sig sig-object py" id="sympy.physics.quantum.hilbert.L2">
<em class="property"><span class="pre">class</span> </em><span class="sig-prename descclassname"><span class="pre">sympy.physics.quantum.hilbert.</span></span><span class="sig-name descname"><span class="pre">L2</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">interval</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/physics/quantum/hilbert.py#L185-L234"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.physics.quantum.hilbert.L2" title="Permalink to this definition">¶</a></dt>
<dd><p>The Hilbert space of square integrable functions on an interval.</p>
<p>An L2 object takes in a single sympy Interval argument which represents
the interval its functions (vectors) are defined on.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">Interval</span><span class="p">,</span> <span class="n">oo</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.physics.quantum.hilbert</span> <span class="kn">import</span> <span class="n">L2</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">hs</span> <span class="o">=</span> <span class="n">L2</span><span class="p">(</span><span class="n">Interval</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span><span class="n">oo</span><span class="p">))</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">hs</span>
<span class="go">L2(Interval(0, oo))</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">hs</span><span class="o">.</span><span class="n">dimension</span>
<span class="go">oo</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">hs</span><span class="o">.</span><span class="n">interval</span>
<span class="go">Interval(0, oo)</span>
</pre></div>
</div>
</dd></dl>

<dl class="py class">
<dt class="sig sig-object py" id="sympy.physics.quantum.hilbert.TensorPowerHilbertSpace">
<em class="property"><span class="pre">class</span> </em><span class="sig-prename descclassname"><span class="pre">sympy.physics.quantum.hilbert.</span></span><span class="sig-name descname"><span class="pre">TensorPowerHilbertSpace</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="o"><span class="pre">*</span></span><span class="n"><span class="pre">args</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/physics/quantum/hilbert.py#L549-L650"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.physics.quantum.hilbert.TensorPowerHilbertSpace" title="Permalink to this definition">¶</a></dt>
<dd><p>An exponentiated Hilbert space <a class="reference internal" href="#r632" id="id7"><span>[R632]</span></a>.</p>
<p>Tensor powers (repeated tensor products) are represented by the
operator <code class="docutils literal notranslate"><span class="pre">**</span></code> Identical Hilbert spaces that are multiplied together
will be automatically combined into a single tensor power object.</p>
<p>Any Hilbert space, product, or sum may be raised to a tensor power. The
<code class="docutils literal notranslate"><span class="pre">TensorPowerHilbertSpace</span></code> takes two arguments: the Hilbert space; and the
tensor power (number).</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.physics.quantum.hilbert</span> <span class="kn">import</span> <span class="n">ComplexSpace</span><span class="p">,</span> <span class="n">FockSpace</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">symbols</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">n</span> <span class="o">=</span> <span class="n">symbols</span><span class="p">(</span><span class="s1">&#39;n&#39;</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">c</span> <span class="o">=</span> <span class="n">ComplexSpace</span><span class="p">(</span><span class="mi">2</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">hs</span> <span class="o">=</span> <span class="n">c</span><span class="o">**</span><span class="n">n</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">hs</span>
<span class="go">C(2)**n</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">hs</span><span class="o">.</span><span class="n">dimension</span>
<span class="go">2**n</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">c</span> <span class="o">=</span> <span class="n">ComplexSpace</span><span class="p">(</span><span class="mi">2</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">c</span><span class="o">*</span><span class="n">c</span>
<span class="go">C(2)**2</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">f</span> <span class="o">=</span> <span class="n">FockSpace</span><span class="p">()</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">c</span><span class="o">*</span><span class="n">f</span><span class="o">*</span><span class="n">f</span>
<span class="go">C(2)*F**2</span>
</pre></div>
</div>
<p class="rubric">References</p>
<dl class="citation">
<dt class="label" id="r632"><span class="brackets">R632</span><span class="fn-backref">(<a href="#id7">1</a>,<a href="#id8">2</a>)</span></dt>
<dd><p><a class="reference external" href="https://en.wikipedia.org/wiki/Hilbert_space#Tensor_products">https://en.wikipedia.org/wiki/Hilbert_space#Tensor_products</a></p>
</dd>
</dl>
</dd></dl>

<dl class="py class">
<dt class="sig sig-object py" id="sympy.physics.quantum.hilbert.TensorProductHilbertSpace">
<em class="property"><span class="pre">class</span> </em><span class="sig-prename descclassname"><span class="pre">sympy.physics.quantum.hilbert.</span></span><span class="sig-name descname"><span class="pre">TensorProductHilbertSpace</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="o"><span class="pre">*</span></span><span class="n"><span class="pre">args</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/physics/quantum/hilbert.py#L282-L436"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.physics.quantum.hilbert.TensorProductHilbertSpace" title="Permalink to this definition">¶</a></dt>
<dd><p>A tensor product of Hilbert spaces <a class="reference internal" href="#r633" id="id9"><span>[R633]</span></a>.</p>
<p>The tensor product between Hilbert spaces is represented by the
operator <code class="docutils literal notranslate"><span class="pre">*</span></code> Products of the same Hilbert space will be combined into
tensor powers.</p>
<p>A <code class="docutils literal notranslate"><span class="pre">TensorProductHilbertSpace</span></code> object takes in an arbitrary number of
<code class="docutils literal notranslate"><span class="pre">HilbertSpace</span></code> objects as its arguments. In addition, multiplication of
<code class="docutils literal notranslate"><span class="pre">HilbertSpace</span></code> objects will automatically return this tensor product
object.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.physics.quantum.hilbert</span> <span class="kn">import</span> <span class="n">ComplexSpace</span><span class="p">,</span> <span class="n">FockSpace</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">symbols</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">c</span> <span class="o">=</span> <span class="n">ComplexSpace</span><span class="p">(</span><span class="mi">2</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">f</span> <span class="o">=</span> <span class="n">FockSpace</span><span class="p">()</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">hs</span> <span class="o">=</span> <span class="n">c</span><span class="o">*</span><span class="n">f</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">hs</span>
<span class="go">C(2)*F</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">hs</span><span class="o">.</span><span class="n">dimension</span>
<span class="go">oo</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">hs</span><span class="o">.</span><span class="n">spaces</span>
<span class="go">(C(2), F)</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">c1</span> <span class="o">=</span> <span class="n">ComplexSpace</span><span class="p">(</span><span class="mi">2</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">n</span> <span class="o">=</span> <span class="n">symbols</span><span class="p">(</span><span class="s1">&#39;n&#39;</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">c2</span> <span class="o">=</span> <span class="n">ComplexSpace</span><span class="p">(</span><span class="n">n</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">hs</span> <span class="o">=</span> <span class="n">c1</span><span class="o">*</span><span class="n">c2</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">hs</span>
<span class="go">C(2)*C(n)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">hs</span><span class="o">.</span><span class="n">dimension</span>
<span class="go">2*n</span>
</pre></div>
</div>
<p class="rubric">References</p>
<dl class="citation">
<dt class="label" id="r633"><span class="brackets">R633</span><span class="fn-backref">(<a href="#id9">1</a>,<a href="#id10">2</a>)</span></dt>
<dd><p><a class="reference external" href="https://en.wikipedia.org/wiki/Hilbert_space#Tensor_products">https://en.wikipedia.org/wiki/Hilbert_space#Tensor_products</a></p>
</dd>
</dl>
<dl class="py method">
<dt class="sig sig-object py" id="sympy.physics.quantum.hilbert.TensorProductHilbertSpace.eval">
<em class="property"><span class="pre">classmethod</span> </em><span class="sig-name descname"><span class="pre">eval</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">args</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/physics/quantum/hilbert.py#L332-L375"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.physics.quantum.hilbert.TensorProductHilbertSpace.eval" title="Permalink to this definition">¶</a></dt>
<dd><p>Evaluates the direct product.</p>
</dd></dl>

<dl class="py property">
<dt class="sig sig-object py" id="sympy.physics.quantum.hilbert.TensorProductHilbertSpace.spaces">
<em class="property"><span class="pre">property</span> </em><span class="sig-name descname"><span class="pre">spaces</span></span><a class="headerlink" href="#sympy.physics.quantum.hilbert.TensorProductHilbertSpace.spaces" title="Permalink to this definition">¶</a></dt>
<dd><p>A tuple of the Hilbert spaces in this tensor product.</p>
</dd></dl>

</dd></dl>

</section>


            <div class="clearer"></div>
          </div>
        </div>
      </div>
      <div class="sphinxsidebar" role="navigation" aria-label="main navigation">
        <div class="sphinxsidebarwrapper">
            <p class="logo"><a href="../../../index.html">
              <img class="logo" src="../../../_static/sympylogo.png" alt="Logo"/>
            </a></p>
  <h4>Previous topic</h4>
  <p class="topless"><a href="cartesian.html"
                        title="previous chapter">Cartesian Operators and States</a></p>
  <h4>Next topic</h4>
  <p class="topless"><a href="operator.html"
                        title="next chapter">Operator</a></p>
  <div role="note" aria-label="source link">
    <h3>This Page</h3>
    <ul class="this-page-menu">
      <li><a href="../../../_sources/modules/physics/quantum/hilbert.rst.txt"
            rel="nofollow">Show Source</a></li>
    </ul>
   </div>
<div id="searchbox" style="display: none" role="search">
  <h3 id="searchlabel">Quick search</h3>
    <div class="searchformwrapper">
    <form class="search" action="https://docs.sympy.org/latest/search.html" method="get">
      <input type="text" name="q" aria-labelledby="searchlabel" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"/>
      <input type="submit" value="Go" />
    </form>
    </div>
</div>
<script>$('#searchbox').show(0);</script>
        </div>
      </div>
      <div class="clearer"></div>
    </div>
    <div class="related" role="navigation" aria-label="related navigation">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="../../../genindex.html" title="General Index"
             >index</a></li>
        <li class="right" >
          <a href="../../../py-modindex.html" title="Python Module Index"
             >modules</a> |</li>
        <li class="right" >
          <a href="operator.html" title="Operator"
             >next</a> |</li>
        <li class="right" >
          <a href="cartesian.html" title="Cartesian Operators and States"
             >previous</a> |</li>
        <li class="nav-item nav-item-0"><a href="../../../index.html">SymPy 1.9 documentation</a> &#187;</li>
          <li class="nav-item nav-item-1"><a href="../../index.html" >SymPy Modules Reference</a> &#187;</li>
          <li class="nav-item nav-item-2"><a href="../index.html" >Physics</a> &#187;</li>
          <li class="nav-item nav-item-3"><a href="index.html" >Quantum Mechanics</a> &#187;</li>
        <li class="nav-item nav-item-this"><a href="#">Hilbert Space</a></li> 
      </ul>
    </div>
    <div class="footer" role="contentinfo">
        &#169; Copyright 2021 SymPy Development Team.
      Last updated on Sep 30, 2021.
      Created using <a href="https://www.sphinx-doc.org/">Sphinx</a> 4.1.2.
    </div>
  </body>

<!-- Mirrored from docs.sympy.org/latest/modules/physics/quantum/hilbert.html by HTTrack Website Copier/3.x [XR&CO'2014], Sat, 15 Jan 2022 03:27:44 GMT -->
</html>